<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Vendor styles -->
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<link rel="stylesheet" href="../css/leftnav.css" />
<style type="text/css">
html,body{
	height: 100%;
}
</style>
</head>
<body>
	<!-- 顶部 -->
	<div class="navbar navbar-duomi navbar-static-top" role="navigation" style="height: 10%;">
        <div class="container-fluid">
            <div class="navbar-header">
                <div class="navbar-brand" href="/Admin/index.html" id="logo">宠物医院信息管理系统
                </div>
            </div>
        </div>
	</div>
	
	<div class="container-fluid">
		<div class="row">
			 <div id='leftnav1' class="col-xs-2" style="margin-top: 100px;margin-bottom: 100px;">
			 <!--导航栏  --><script>
	var sf = getCookie('staff');
	if(isNotEmpty(sf)){
		$('#'+sf).siblings("li.panel").hide();
	}

</script>


<ul id="accordion" class="main-nav nav nav-tabs nav-stacked" >
      <li class="active">
              <%-- 全局修改三 : a标签调转 http://localhost/qiantai/index.jsp--%>
              <a href="http://localhost/qiantai/index.jsp"><i class="glyphicon glyphicon-th-large"></i>首页</a>
      </li>

      <li class="panel">
          <a href="#role" class="nav-header collapsed" data-toggle="collapse" data-parent="#accordion">
              <i class="glyphicon glyphicon-cog"></i>科室管理<span class="pull-right glyphicon glyphicon-chevron-down"></span>
          </a>
          <ul id="role" class="nav nav-list collapse secondmenu" style="height: 0px;">
              <li><a href="role.jsp"><i class="glyphicon glyphicon-user"></i>查看科室</a></li>
              <li><a href="role_add.jsp"><i class="glyphicon glyphicon-th-list"></i>增加科室</a></li>
          </ul>
      </li>
      <li class="panel">
          <a href="#staff" class="nav-header collapsed" data-toggle="collapse" data-parent="#accordion">
              <i class="glyphicon glyphicon-cog"></i>医生管理<span class="pull-right glyphicon glyphicon-chevron-down"></span>
          </a>
          <ul id="staff" class="nav nav-list collapse secondmenu" style="height: 0px;">
              <li><a href="staff.jsp"><i class="glyphicon glyphicon-user"></i>查看医生</a></li>
              <li><a href="staff_add.jsp"><i class="glyphicon glyphicon-th-list"></i>增加医生</a></li>
          </ul>
      </li>
      <li class="panel">
          <a href="#user" class="nav-header collapsed" data-toggle="collapse" data-parent="#accordion">
              <i class="glyphicon glyphicon-cog"></i>用户管理<span class="pull-right glyphicon glyphicon-chevron-down"></span>
          </a>
          <ul id="user" class="nav nav-list collapse secondmenu" style="height: 0px;">
              <li><a href="user.jsp"><i class="glyphicon glyphicon-user"></i>查看用户</a></li>
              <li><a href="user_add.jsp"><i class="glyphicon glyphicon-th-list"></i>增加用户</a></li>
          </ul>
      </li>

      <li class="panel" id="role2">
          <a href="#repair" class="nav-header collapsed" data-toggle="collapse" data-parent="#accordion">
              <i class="glyphicon glyphicon-cog"></i>病例管理<span class="pull-right glyphicon glyphicon-chevron-down"></span>
          </a>
          <ul id="repair" class="nav nav-list collapse secondmenu" style="height: 0px;">
              <li><a href="repair.jsp"><i class="glyphicon glyphicon-user"></i>查看病例</a></li>
              <li><a href="repair_add.jsp"><i class="glyphicon glyphicon-th-list"></i>增加病例</a></li>
          </ul>
      </li>
      <li class="panel" id="role3">
          <a href="#complaints" class="nav-header collapsed" data-toggle="collapse" data-parent="#accordion">
              <i class="glyphicon glyphicon-cog"></i>美容管理<span class="pull-right glyphicon glyphicon-chevron-down"></span>
          </a>
          <ul id="complaints" class="nav nav-list collapse secondmenu" style="height: 0px;">
              <li><a href="complaints.jsp"><i class="glyphicon glyphicon-user"></i>查看美容信息</a></li>
              <li><a href="complaints_add.jsp"><i class="glyphicon glyphicon-th-list"></i>增加美容信息</a></li>
          </ul>
      </li>
      <li class="">
          <a href="../index.jsp"><i class="glyphicon glyphicon-th-large"></i>安全退出</a>
      </li>
</ul>
			 </div>
			 
			 <div id='leftnav2' class="col-xs-10">
			 
			 <div class="page-header">
			    <h1>查看病例记录
			        <small>
			        	<a href="paymentbill_add.jsp">添加病例</a>
			        </small>
			    </h1>
			</div>
			<!--搜索模块-->
			 <div class='col-xs-3'>
			 <input id="search_name" type='text' class="form-control" placeholder="按宠物名搜索">
			 </div>
			 <div class='col-xs-3'>
			 <input id="search_building" type='text' class="form-control" placeholder="按宠物编号搜索">
			 </div>
			 <div class='col-xs-3'>
			 <input id="search_houseNum" type='text' class="form-control" placeholder="按宠物症状搜索">
			 </div>
			 <button type="button" id='serach_bt' class="btn" style="background: #3C4049;color:#fff;">搜索</button>
			 
			 <br/>
			 <table class="table table-striped">
				  <thead>
				    <tr>
				      <th>序号</th>
			          <th>宠物名</th>
			          <th>主人名</th>
			          <th>宠物编号</th>
			          <th>宠物症状</th>
			          <th>就诊日期</th>
			          <th>处理</th>
			          <th>宠物品种</th>
		              <th>操作</th>
				    </tr>
				  </thead>
				  <tbody id="content_body">
				  </tbody>
				</table>
				
				<div class="row" id='pager-div'> 
			        <div class="col-xs-12"> 
			         <span class="pagination_count">共<span id="sum_count"></span>条记录 | 第<span id="page_num">1</span>页 </span> 
			         <ul class="pager" id="mypager"> 
			          <li class="current sy"><a>首页</a></li> 
			          <li class="current syy"><a>上一页</a></li> 
			          <li class="current xyy"><a>下一页</a></li> 
			          <li class="current wy"><a>尾页</a></li> 
			         </ul> 
			        </div> 
			   </div>
			   
			 </div>
		</div> 
	</div>
	
	<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap.min.js"></script>
	<script type="text/javascript" src="../js/public_fuc.js"></script> 
  <script type="text/javascript">  
	$(function(){
		$("#leftnav").load("pubnav.html");
		var obj = {};
		loadData(1,obj);
	});
	var number = 10;
	var flag = true;
	var loadData = function(page,obj){
		obj.page = page;
		obj.number = number;
		$.get("../api/paymentbill/list",obj,function(data){
			if (data.code==0) {
				var arr = data.data;
				var html = '';
				for (var i=0,len=arr.length;i<len;i++) {
					var obj = arr[i];
					//console.log(obj);
					
					 var state = obj.state;
			    	 if(state=='0'){
			    		 state = '存在病史'
			    	 }else if(state=='1'){
			    		 state = '暂无病史'
			    	 }else if(state=='2'){
			    		 state = '有待观察';
			    	 }
					
					
					html += '<tr id="'+obj.id+'">' 
			               +'<td>'+(i+1)+'</td>'
						    +'<td>'+obj.name+'</td>'
						    +'<td>'+obj.cost+'</td>'
						    +'<td>'+obj.building+'</td>'
						    +'<td>'+obj.houseNum+'</td>'
						    +'<td>'+obj.cpTime+'</td>'
						    +'<td>'+state+'</td>'
						    +'<td>'+obj.remark+'</td>'
			               +'<td >'
				               +'<a href="paymentbill_edit.jsp?'+$.param(obj)+'"  title="编辑" >编辑</a>&nbsp;&nbsp;'
				               +'<a title="删除" class="del">删除</a>'
			               +'</td>'
			               +'</tr>';
				}
				document.getElementById('content_body').innerHTML = html;
				document.getElementById('sum_count').innerHTML = data.count;
				opera();
				//分页操作
				if(flag){
					pagebutton(data.pages);
					flag = false;					
				}
			} else {
				$("#pager-div").addClass('hidden');
				document.getElementById('content_body').innerHTML = '<tr><td style="color:red;font-size:1.3em;">暂无物品</td></tr>';
			}
		});
	}
	
	
	
	function opera(){
		$('#content_body').on('click','tr',function(e){
			//filter phone
			var tid  = e.currentTarget.id;
			if(e.target.className=='del'){
				var obj = {};
				obj.id = tid;
				$.get('../api/paymentbill/remove',obj,function(data){
					if(data.code==0){
						window.location.reload();
					}
				});
			}
		});
		
	}
	
	$('#serach_bt').click(function(){
		var obj = {};
		obj.name = $('#search_name').val();
		obj.building = $('#search_building').val();
		obj.houseNum = $('#search_houseNum').val();
		loadData(1,obj);
	 });
 </script>  
</body>
</html>